package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-04-09
 * Time: 10:05
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("hello world");
        MySingleList mySingleList = new MySingleList();
        mySingleList.createList();
        mySingleList.showList();
        System.out.println();
        System.out.println("单链表长度为：" + mySingleList.size());
        System.out.println("是否有某元素：" + mySingleList.contains(13));
        mySingleList.addFirst(10);         //头插法
        mySingleList.showList();
        System.out.println();
        mySingleList.addLast(100);         //尾插法
        mySingleList.showList();
        System.out.println();
        try{
            mySingleList.addIndex(2, 1000);     //在下标为index的位置上添加一个数data
        }catch (IndexOutOfBounds indexOutOfBounds){
            indexOutOfBounds.printStackTrace();
        }
        //mySingleList.addIndex(111, 1000);
        mySingleList.showList();
        System.out.println();
        mySingleList.removeAllKey(100);    //移除key单个关键字
        mySingleList.showList();
        System.out.println();
 /*       mySingleList.removeAllKey(12);    //移除所有的key关键字
        mySingleList.showList();
        System.out.println();
*//*        mySingleList.clear();             //清空链表
        mySingleList.showList();*//*
        mySingleList.removeAllKey(56);
        mySingleList.addLast(42);
        mySingleList.showList();*/
    }
}
